#!/bin/bash
let "gtnum=0"
find_target_file(){
  for i in $(ls)
    do
      if [ -d $i ]
      then
        cd $i;
        # if is directory, find the target file recurrently.
        find_target_file
        cd ..
      else
        # match the pattern.
        if [[ $i == *_gt.json* ]]
          then
            # count the target file number.
            let gtnum+=1
        fi
      fi
    done
}

cd $1
find_target_file
echo "The number of filtered files with "_gt.json" is $gtnum"

